#!/usr/bin/bash

# 设置交叉编译工具链
export CC=arm-linux-gnueabihf-gcc
export CXX=arm-linux-gnueabihf-g++
export AR=arm-linux-gnueabihf-ar
export STRIP=arm-linux-gnueabihf-strip

# 创建并进入构建目录
mkdir -p cmake-build-release-wsl_arm
cd cmake-build-release-wsl_arm || exit 1

# 运行CMake配置
cmake ../cmake/ \
    -DCMAKE_SYSTEM_NAME=Linux \
    -DCMAKE_SYSTEM_PROCESSOR=arm \
    -DCMAKE_C_COMPILER=${CC} \
    -DCMAKE_CXX_COMPILER=${CXX} \
    -DBUILD_SHARED_LIBS=ON \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_CXX_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=hard" \
    -DCMAKE_C_FLAGS="-march=armv7-a -mfpu=neon -mfloat-abi=hard"

# 编译并安装
make -j$(nproc) -s || exit 1
make install || exit 1
